package org.jflame.web.spring.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * controller基类
 *
 * @author charles.zhang
 */
public abstract class BaseController {

    protected final Logger logger = LoggerFactory.getLogger(getClass());

    /*@InitBinder
    protected void ininBinder(WebDataBinder binder) {
        // 注册时间转换器
        binder.addCustomFormatter(new MyDateFormatter<>(java.util.Date.class), java.util.Date.class);
        binder.addCustomFormatter(new MyDateFormatter<>(java.sql.Timestamp.class), java.sql.Timestamp.class);
        binder.addCustomFormatter(new MyDateFormatter<>(java.sql.Date.class), java.sql.Date.class);
        binder.addCustomFormatter(new MyDateFormatter<>(java.sql.Time.class), java.sql.Time.class);

        binder.addCustomFormatter(new MyTemporalFormatter<>(LocalDateTime.class), LocalDateTime.class);
        binder.addCustomFormatter(new MyTemporalFormatter<>(LocalDate.class), LocalDate.class);
        binder.addCustomFormatter(new MyTemporalFormatter<>(LocalTime.class), LocalTime.class);
    }*/
    
    /**
     * 获取HttpSession
     *
     * @param request HttpServletRequest
     * @return 返回请求的session对象, 如果不存在则返回null
     */
    protected HttpSession getSession(HttpServletRequest request) {
        return request.getSession(false);
    }

}
